True if this instance could stand at (x, y) without overlapping a SOLID instance of obj (excluding itself). Name more objects after the first and it is true only if none of them is in the way: pos_free(x, y, obj_wall, obj_rock).
pos_free(x, y, obj, ...more) -> bool| Name | Type |
|---|---|
x | real |
y | real |
obj | object |
...more | object (any number of them, none included) |
bool
True if this instance could stand at (x, y) without overlapping a SOLID instance of obj - excluding itself. The standard "is this move even legal" check most of the rest of this group builds on.
x and y are a place in the room, counted from the room's top-left corner, the same way this instance's own x and y are counted.
If obj is a parent, its children count as obj too. With obj_enemy as the parent of obj_slime, a solid slime in the way blocks you exactly like a solid obj_enemy. Overlap and collision lists everywhere a parent's name reaches its children.
You can name more than one object: pos_free(x, y, obj_wall, obj_rock) is true only when none of them is in the way, each one counted together with its children. Name as many as you like; one named twice is checked once.
Only an obj instance with solid set to true counts; one that never sets it is invisible to this check, the same as if it were not there at all. By default the scan is a plain linear pass over the pool of obj (and of each of its children), not a spatial index - deliberately, the same "pools are small" reasoning instance_nearest already relies on, not something to call from many instances at once every frame without thinking about it. An object whose Never moves box is ticked is the exception: its copies are kept in a look-up grid and the answer comes from there, the same answer for far less work (Never moves).
An instance destroyed earlier in the same frame still counts for this check until the end of the frame, because instance_destroy only ends it then. The one exception is a Collision event, which skips it at once.
An instance with no sprite and no mask size is a single point. A box meets that point only when the point is strictly inside it - past its left and top edges and short of its right and bottom edges. A point exactly on an edge or a corner is not met, and two boxes with no size never meet. (Overlap and collision has the whole rule.) So a solid instance with no size blocks a box that has its point strictly inside, and an instance with no size is blocked by a solid box that has its own point strictly inside.
if (pos_free(x + hsp, y + vsp, obj_doc_wall)) {
x += hsp;
y += vsp;
}Only advances the walker along its current hsp/vsp if the next position would not overlap a solid obj_doc_wall instance - the plain, non-sliding version of the check move_slide already runs internally.
Linear over obj’s own pool and each descendant’s, because a parent’s name covers its children. Only instances with `solid = true` count. An object whose Never moves box is ticked is answered from a lookup grid instead (same answer). Any number of objects may be named; each one is checked together with its children, and an object named twice is checked once. An instance with no sprite and no mask size is a single point at its x and y (moved by mask_x and mask_y). A box meets that point only when the point lies strictly inside it, past its left and top edges and short of its right and bottom edges; a point exactly on an edge or a corner is not met, and two boxes with no size never meet, even in the same spot. A box with a width and no height (or the reverse) is a line, met when it lies strictly between the edges of the other box across its empty side. A solid instance with no size therefore blocks a box that has its point strictly inside, and pos_free is false for an instance with no size whose own point is strictly inside a solid box.